import axios from "axios";
import NProgress from "nprogress";
import  "nprogress/nprogress.css"

// 创建一个实例
let instance=axios.create({
    baseURL:"/sph",
    timeout:5000
})

// 请求拦截
instance.interceptors.request.use((config)=>{
    NProgress.start()
    return config
})

// 响应拦截
instance.interceptors.response.use(
  
  (response)=>{
    NProgress.done()
    switch(response.data.code){
        case 200:
            return response.data.data;
          
        default:
            return response.data
    }
  

  },
  (error)=>{

    NProgress.done()
return Promise.reject()
  }

)

export default instance